package UnOfficeDeTourisme;

/** 
 * Helper class for : Entree
 *  
 * @author OpenORB Compiler
 */ 
public class EntreeHelper
{
    private static final boolean HAS_OPENORB;
    static {
        boolean hasOpenORB = false;
        try {
            Thread.currentThread().getContextClassLoader().loadClass("org.openorb.CORBA.Any");
            hasOpenORB = true;
        }
        catch(ClassNotFoundException ex) {
        }
        HAS_OPENORB = hasOpenORB;
    }
    /**
     * Insert Entree into an any
     * @param a an any
     * @param t Entree value
     */
    public static void insert(org.omg.CORBA.Any a, UnOfficeDeTourisme.Entree t)
    {
        a.insert_Streamable(new UnOfficeDeTourisme.EntreeHolder(t));
    }

    /**
     * Extract Entree from an any
     * @param a an any
     * @return the extracted Entree value
     */
    public static UnOfficeDeTourisme.Entree extract(org.omg.CORBA.Any a)
    {
        if (!a.type().equal(type()))
            throw new org.omg.CORBA.MARSHAL();
        if (HAS_OPENORB && a instanceof org.openorb.CORBA.Any) {
            // streamable extraction. The jdk stubs incorrectly define the Any stub
            org.openorb.CORBA.Any any = (org.openorb.CORBA.Any)a;
            try {
                org.omg.CORBA.portable.Streamable s = any.extract_Streamable();
                if(s instanceof UnOfficeDeTourisme.EntreeHolder)
                    return ((UnOfficeDeTourisme.EntreeHolder)s).value;
            } catch (org.omg.CORBA.BAD_INV_ORDER ex) {
            }
            UnOfficeDeTourisme.EntreeHolder h = new UnOfficeDeTourisme.EntreeHolder(read(a.create_input_stream()));
            a.insert_Streamable(h);
            return h.value;
        }
        return read(a.create_input_stream());
    }

    //
    // Internal TypeCode value
    //
    private static org.omg.CORBA.TypeCode _tc = null;
    private static boolean _working = false;

    /**
     * Return the Entree TypeCode
     * @return a TypeCode
     */
    public static org.omg.CORBA.TypeCode type()
    {
        if (_tc == null) {
            synchronized(org.omg.CORBA.TypeCode.class) {
                if (_tc != null)
                    return _tc;
                if (_working)
                    return org.omg.CORBA.ORB.init().create_recursive_tc(id());
                _working = true;
                org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
                org.omg.CORBA.StructMember []_members = new org.omg.CORBA.StructMember[9];

                _members[0] = new org.omg.CORBA.StructMember();
                _members[0].name = "idEntree";
                _members[0].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
                _members[1] = new org.omg.CORBA.StructMember();
                _members[1].name = "visiteEntree";
                _members[1].type = UnOfficeDeTourisme.iorHelper.type();
                _members[2] = new org.omg.CORBA.StructMember();
                _members[2].name = "carteEntree";
                _members[2].type = UnOfficeDeTourisme.iorHelper.type();
                _members[3] = new org.omg.CORBA.StructMember();
                _members[3].name = "valable";
                _members[3].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_boolean);
                _members[4] = new org.omg.CORBA.StructMember();
                _members[4].name = "dateEntree";
                _members[4].type = UnOfficeDeTourisme.datecutHelper.type();
                _members[5] = new org.omg.CORBA.StructMember();
                _members[5].name = "dateSortie";
                _members[5].type = UnOfficeDeTourisme.datecutHelper.type();
                _members[6] = new org.omg.CORBA.StructMember();
                _members[6].name = "avis";
                _members[6].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string);
                _members[7] = new org.omg.CORBA.StructMember();
                _members[7].name = "nbEntreesType";
                _members[7].type = UnOfficeDeTourisme.hashMapTypeEntreeId_nbEntreesHelper.type();
                _members[8] = new org.omg.CORBA.StructMember();
                _members[8].name = "typesEntree";
                _members[8].type = UnOfficeDeTourisme.hashMapObectId_IORHelper.type();
                _tc = orb.create_struct_tc(id(),"Entree",_members);
                _working = false;
            }
        }
        return _tc;
    }

    /**
     * Return the Entree IDL ID
     * @return an ID
     */
    public static String id()
    {
        return _id;
    }

    private final static String _id = "IDL:UnOfficeDeTourisme/Entree:1.0";

    /**
     * Read Entree from a marshalled stream
     * @param istream the input stream
     * @return the readed Entree value
     */
    public static UnOfficeDeTourisme.Entree read(org.omg.CORBA.portable.InputStream istream)
    {
        UnOfficeDeTourisme.Entree new_one = new UnOfficeDeTourisme.Entree();

        new_one.idEntree = istream.read_long();
        new_one.visiteEntree = UnOfficeDeTourisme.iorHelper.read(istream);
        new_one.carteEntree = UnOfficeDeTourisme.iorHelper.read(istream);
        new_one.valable = istream.read_boolean();
        new_one.dateEntree = UnOfficeDeTourisme.datecutHelper.read(istream);
        new_one.dateSortie = UnOfficeDeTourisme.datecutHelper.read(istream);
        new_one.avis = istream.read_string();
        new_one.nbEntreesType = UnOfficeDeTourisme.hashMapTypeEntreeId_nbEntreesHelper.read(istream);
        new_one.typesEntree = UnOfficeDeTourisme.hashMapObectId_IORHelper.read(istream);

        return new_one;
    }

    /**
     * Write Entree into a marshalled stream
     * @param ostream the output stream
     * @param value Entree value
     */
    public static void write(org.omg.CORBA.portable.OutputStream ostream, UnOfficeDeTourisme.Entree value)
    {
        ostream.write_long(value.idEntree);
        UnOfficeDeTourisme.iorHelper.write(ostream,value.visiteEntree);
        UnOfficeDeTourisme.iorHelper.write(ostream,value.carteEntree);
        ostream.write_boolean(value.valable);
        UnOfficeDeTourisme.datecutHelper.write(ostream,value.dateEntree);
        UnOfficeDeTourisme.datecutHelper.write(ostream,value.dateSortie);
        ostream.write_string(value.avis);
        UnOfficeDeTourisme.hashMapTypeEntreeId_nbEntreesHelper.write(ostream,value.nbEntreesType);
        UnOfficeDeTourisme.hashMapObectId_IORHelper.write(ostream,value.typesEntree);
    }

}
